package com.company.lagou.homework.homework2;

import com.company.lagou.task16.AgeException;

public class Student {
    private String ID;
    private String name;
    private int age;

    public Student() {
    }

    public Student(String ID, String name, int age) {
        this.ID = ID;
        this.name = name;
        this.age = age;
    }

    public String getID() {
        return ID;
    }

    public void setID(String ID) /*throw Exception*/ {
        this.ID = ID;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) /*throws AgeException*/ {
        if (age > 0 && age < 150) {
            this.age = age;
        } else {
            // System.out.println("年龄不合理！！");
            try {
                throw new AgeException("年龄不合理哦！！");
            } catch (AgeException e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public String toString() {
        return "Student{" +
                "ID='" + ID + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

}
